import { defineStore } from "pinia";
import { ref,reactive } from "vue";
export const useMenuStore = defineStore("menu",()=>{
    // 菜单
    const menus = reactive({});
    // 修改access_token
    function setMenus(menu){
        Object.assign(menus,menu);
    }
    /**
     * 混合模式左侧菜单列表
     */
    const mixLeftMenus = ref();
    /**
     * 混合模式菜单下根据顶部菜单路径设置左侧菜单
     *
     * @param topMenuPath - 顶部菜单路径
     */
    const setMixLeftMenus = (topMenuPath) => {
        const matchedItem = menus.value.find((item) => item.path === topMenuPath);
        if (matchedItem && matchedItem.children) {
            mixLeftMenus.value = matchedItem.children;
        }
    };
    return {
        menus,
        mixLeftMenus,
        setMenus,
        setMixLeftMenus
    }
},{
    persist:[
        {
            key:'menus',
            paths:['menus'],
        }
    ],
});